package cn.xsly.ymcc.service.impl;

import cn.xsly.ymcc.domain.MessageStation;
import cn.xsly.ymcc.dto.StationMessageDto;
import cn.xsly.ymcc.mapper.MessageStationMapper;
import cn.xsly.ymcc.service.IMessageStationService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author whale
 * @since 2022-10-19
 */
@Service
public class MessageStationServiceImpl extends ServiceImpl<MessageStationMapper, MessageStation> implements IMessageStationService {

    @Override
    public void save(StationMessageDto stationInMQDto) {
            List<Long> ids = stationInMQDto.getIds();
            Date date = new Date();
        /*
            insert into table(...) values（），（），（）
         */
            ids.forEach(id->{
                MessageStation station = new MessageStation();
                station.setTitle(stationInMQDto.getTitle());
                station.setContent(stationInMQDto.getContent());
                station.setIsread(0);
                station.setUserId(id);
                station.setSendTime(date);
                insert(station);
            });
    }
}
